<?php
namespace app\servergoods\validate;
use \app\manage\validate\BaseValidate;

class Goods extends BaseValidate
{
    //验证规则
	protected $rule =   [
        'id'    => ['integer','gt'=>0],
        'status'=> ['in'=>'0,1'],
        //'recommend' => ['regex' => '^(\w)+(,\w+)*'],  //  brand,person
        'recommend' => ['min'=>2],  //  brand,person
        'symbol' => ['in'=>'elt,between,egt'], 
        'price_start' => ['integer','egt'=>0],
        'price_end' => ['integer','egt'=>0], 
        'goods_belonger_name' => ['min'=>2], 
        'cate_id' => ['integer','gt'=>0],
        'title' => ['min'=>2], 
        'imgs_urls'=> ['min'=>'1'],
        'imgs_ids' => ['min'=>'1'],
        'price'=> ['integer','gt'=>0],
        'goods_attrs'=> ['array'],
        'organization' => ['min'=>2],
        'orther_info'=> ['array'],
        'product_code' => ['min'=>'10'],
        'origin_number' => ['integer','gt'=>0],
        'pick_up_time' => ['integer','gt'=>0],
        'start_delivery_time' => ['integer','egt'=>0],
        'end_delivery_time' => ['egt'=>'start_delivery_time'],
        /*账单验证*/
        'goods_id'  => ['integer','gt'=>0],
        'order_number'  => ['integer','gt'=>0],
        'total_price'  => ['integer'],
        'remark'  => ['min'=>2],
    ];

    protected $message  =   [
        'goods_belonger_name' => ['所属艺术家最少字段为2'],
        'cate_id' => ['所属分类错误'],
        'title' => ['标题最少字段为2'],
        'imgs_urls' => ['请传入商品图片'],
        'imgs_ids' => ['请传入商品图片'],
        'price' => ['价格错误'],
        'organization' => ['请填写认证机构'],
        'origin_number' => ['商品原始数量为正整数'],
        'pick_up_time' => ['请重新填写最晚提货时间'],
    ];

    protected $scene = [
        'goodsAllDetail' => ['id'],
        /*管理员操作单个商品时的验证*/
        'manageDelGoods' => ['id'],
        /*管理员批量操作商品时的验证*/
        'manageBatchDelGoods' => [
            'id'  => ['require','array','min'=>1]
        ],
        'auditOneGoods' => ['id','status'=> ['in'=>'1,2']],
        'soldOutOneGoods' => ['id'],
        'batchAuditGoods' => ['id'=> ['require','array','min'=>1],'status'=> ['in'=>'1,2']],
        'soldOutBatchGoods' => ['id'=> ['require','array','min'=>1]],
        'adminGoodsList' => [
        	'status'=> ['in'=>'-1,0,1,2,3,4'],
        	'page'=>['require','integer','gt'=>0],
        	'listRows'=>['require','integer', 'between'=>'1,100'],
        	'cate_id' => ['integer','egt'=>0],
            'price_start' => ['integer','egt'=>0],
            'price_end' => ['integer','egt'=>0],
            'symbol'
        ],
        /*管理员推荐某个商品*/
        'recommend' => ['id', 'recommend'],
        'yihuoAddGoods' => ['goods_belonger_name','cate_id','title','imgs_ids','imgs_urls','price','goods_attrs','organization','orther_info','product_code','origin_number','pick_up_time','start_delivery_time','end_delivery_time','token'],
        'yihuoEditGoods' => ['id'=> ['require','integer','gt'=>0],'user_id'=> ['require','integer','gt'=>0],'app_id'=> ['require','integer','gt'=>0],'goods_belonger_name','cate_id','title','imgs_urls','imgs_ids','desc','price','goods_attrs','number','origin_number','pay_method','delivery_type','province','city','county','order','pick_up_time','start_delivery_time','end_delivery_time'],
    ];

}